﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace monitor_server_2_WPF
{
    /// <summary>
    /// Логика взаимодействия для FloatingInfos.xaml
    /// </summary>
    public partial class FloatingInfos
    {

        private readonly Dictionary<string, Label> _infos; 

        public FloatingInfos()
        {
            InitializeComponent();
            _infos = new Dictionary<string, Label>();
        }

        public void AddInfo(string id, string value, Brush foreground = null)
        {
            if (foreground == null)
                foreground = new SolidColorBrush(Res.InvalidInputInfoColor);
            var l = new Label
                {
                    Content = value,
                    Foreground = foreground,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Visibility = Visibility.Collapsed
                };
            _infos.Add(id, l);
            ContentPanel.Children.Add(l);
        }

        public void ShowInfo(string id)
        {
            _infos[id].Visibility = Visibility.Visible;
            var a = new DoubleAnimation(0.0, 1.0, new Duration(new TimeSpan(0, 0, 0, 1)));
            _infos[id].BeginAnimation(OpacityProperty, a);
        }

        public void HideInfo(string id)
        {
            _infos[id].Visibility = Visibility.Collapsed;
        }
    }
}
